package com.qf.java2105.huangchuang.hotel.controller.user;

import cn.dsna.util.images.ValidateCode;
import com.qf.java2105.huangchuang.hotel.constant.ResponseMessageConstant;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author hcvg
 * @version v1.0
 * @date 2021/09/16
 **/
@WebServlet("/getValidateCode")
public class ValidateController extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ValidateCode validateCode = new ValidateCode();
        request.getSession().setAttribute("validateCode", validateCode.getCode());
        validateCode.write(response.getOutputStream());
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
